// model.hpp
//

#ifndef _MODEL_HPP
#define _MODEL_HPP

#include "base.hpp"



// Texture
//
struct Texture
{
  Texture ( std::string path )
    : path(path)
  {
  }

  void bind ()
  {
    if (!uploaded)
      {
        wgl_texture.load(path);
        wgl_texture.upload();
        uploaded = true;
      }
    gl.BindTexture(GL_TEXTURE_2D, wgl_texture.get_id());
  }
  
  std::string path;
  wgl::Texture wgl_texture{};
  bool uploaded{false};
};



// Model
//
struct Model
{
  void upload ()
  {
    if (!uploaded)
      {
        buffer.upload(mesh);
        uploaded = true;
      }
  }
  
  wgl::Mesh mesh{};
  wgl::MeshBuffer buffer{};
  bool uploaded{false};
};



#endif
